home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  10.6 KB  |  280 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1986-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __ADSP__
  19. #define __ADSP__
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. /*driver control csCodes*/
  51.  
  52. enum {
  53.     dspInit                        = 255,                            /* create a new connection end */
  54.     dspRemove                    = 254,                            /* remove a connection end */
  55.     dspOpen                        = 253,                            /* open a connection */
  56.     dspClose                    = 252,                            /* close a connection */
  57.     dspCLInit                    = 251,                            /* create a connection listener */
  58.     dspCLRemove                    = 250,                            /* remove a connection listener */
  59.     dspCLListen                    = 249,                            /* post a listener request */
  60.     dspCLDeny                    = 248,                            /* deny an open connection request */
  61.     dspStatus                    = 247,                            /* get status of connection end */
  62.     dspRead                        = 246,                            /* read data from the connection */
  63.     dspWrite                    = 245,                            /* write data on the connection */
  64.     dspAttention                = 244,                            /* send an attention message */
  65.     dspOptions                    = 243,                            /* set connection end options */
  66.     dspReset                    = 242,                            /* forward reset the connection */
  67.     dspNewCID                    = 241                            /* generate a cid for a connection end */
  68. };
  69.  
  70.  
  71. enum {
  72.                                                                 /* connection opening modes */
  73.     ocRequest                    = 1,                            /* request a connection with remote */
  74.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  75.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  76.     ocEstablish                    = 4                                /* consider connection to be open */
  77. };
  78.  
  79.  
  80. enum {
  81.                                                                 /* connection end states */
  82.     sListening                    = 1,                            /* for connection listeners */
  83.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  84.     sOpening                    = 3,                            /* requesting a connection with remote */
  85.     sOpen                        = 4,                            /* connection is open */
  86.     sClosing                    = 5,                            /* connection is being torn down */
  87.     sClosed                        = 6                                /* connection end state is closed */
  88. };
  89.  
  90.  
  91. enum {
  92.                                                                 /* client event flags */
  93.     eClosed                        = 0x80,                            /* received connection closed advice */
  94.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  95.     eAttention                    = 0x20,                            /* received attention message */
  96.     eFwdReset                    = 0x10                            /* received forward reset advice */
  97. };
  98.  
  99.  
  100. enum {
  101.                                                                 /* miscellaneous constants */
  102.     attnBufSize                    = 570,                            /* size of client attention buffer */
  103.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  104. };
  105.  
  106. /* connection control block */
  107. typedef struct TRCCB                     TRCCB;
  108. typedef TRCCB *                            TPCCB;
  109.  
  110. struct TRCCB {
  111.     TPCCB                             ccbLink;                    /* link to next ccb */
  112.     UInt16                             refNum;                        /* user reference number */
  113.     UInt16                             state;                        /* state of the connection end */
  114.     UInt8                             userFlags;                    /* flags for unsolicited connection events */
  115.     UInt8                             localSocket;                /* socket number of this connection end */
  116.     AddrBlock                         remoteAddress;                /* internet address of remote end */
  117.     UInt16                             attnCode;                    /* attention code received */
  118.     UInt16                             attnSize;                    /* size of received attention data */
  119.     void *                            attnPtr;                    /* ptr to received attention data */
  120.     UInt8                             reserved[220];                /* for adsp internal use */
  121. };
  122.  
  123. typedef CALLBACK_API( void , ADSPConnectionEventProcPtr )(TPCCB sourceCCB);
  124. /*
  125.     WARNING: ADSPConnectionEventProcPtr uses register based parameters under classic 68k
  126.              and cannot be written in a high-level language without 
  127.              the help of mixed mode or assembly glue.
  128. */
  129. typedef struct DSPParamBlock             DSPParamBlock;
  130. typedef DSPParamBlock *                    DSPPBPtr;
  131. typedef CALLBACK_API( void , ADSPCompletionProcPtr )(DSPPBPtr thePBPtr);
  132. /*
  133.     WARNING: ADSPCompletionProcPtr uses register based parameters under classic 68k
  134.              and cannot be written in a high-level language without 
  135.              the help of mixed mode or assembly glue.
  136. */
  137. typedef REGISTER_UPP_TYPE(ADSPConnectionEventProcPtr)             ADSPConnectionEventUPP;
  138. typedef REGISTER_UPP_TYPE(ADSPCompletionProcPtr)                 ADSPCompletionUPP;
  139.  
  140. struct TRinitParams {
  141.     TPCCB                             ccbPtr;                        /* pointer to connection control block */
  142.     ADSPConnectionEventUPP             userRoutine;                /* client routine to call on event */
  143.     UInt16                             sendQSize;                    /* size of send queue (0..64K bytes) */
  144.     void *                            sendQueue;                    /* client passed send queue buffer */
  145.     UInt16                             recvQSize;                    /* size of receive queue (0..64K bytes) */
  146.     void *                            recvQueue;                    /* client passed receive queue buffer */
  147.     void *                            attnPtr;                    /* client passed receive attention buffer */
  148.     UInt8                             localSocket;                /* local socket number */
  149.     UInt8                             filler1;                    /* filler for proper byte alignment */
  150. };
  151. typedef struct TRinitParams                TRinitParams;
  152.  
  153. struct TRopenParams {
  154.     UInt16                             localCID;                    /* local connection id */
  155.     UInt16                             remoteCID;                    /* remote connection id */
  156.     AddrBlock                         remoteAddress;                /* address of remote end */
  157.     AddrBlock                         filterAddress;                /* address filter */
  158.     UInt32                             sendSeq;                    /* local send sequence number */
  159.     UInt16                             sendWindow;                    /* send window size */
  160.     UInt32                             recvSeq;                    /* receive sequence number */
  161.     UInt32                             attnSendSeq;                /* attention send sequence number */
  162.     UInt32                             attnRecvSeq;                /* attention receive sequence number */
  163.     UInt8                             ocMode;                        /* open connection mode */
  164.     UInt8                             ocInterval;                    /* open connection request retry interval */
  165.     UInt8                             ocMaximum;                    /* open connection request retry maximum */
  166.     UInt8                             filler2;                    /* filler for proper byte alignment */
  167. };
  168. typedef struct TRopenParams                TRopenParams;
  169.  
  170. struct TRcloseParams {
  171.     UInt8                             abort;                        /* abort connection immediately if non-zero */
  172.     UInt8                             filler3;                    /* filler for proper byte alignment */
  173. };
  174. typedef struct TRcloseParams            TRcloseParams;
  175.  
  176. struct TRioParams {
  177.     UInt16                             reqCount;                    /* requested number of bytes */
  178.     UInt16                             actCount;                    /* actual number of bytes */
  179.     void *                            dataPtr;                    /* pointer to data buffer */
  180.     UInt8                             eom;                        /* indicates logical end of message */
  181.     UInt8                             flush;                        /* send data now */
  182. };
  183. typedef struct TRioParams                TRioParams;
  184.  
  185. struct TRattnParams {
  186.     UInt16                             attnCode;                    /* client attention code */
  187.     UInt16                             attnSize;                    /* size of attention data */
  188.     void *                            attnData;                    /* pointer to attention data */
  189.     UInt8                             attnInterval;                /* retransmit timer in 10-tick intervals */
  190.     UInt8                             filler4;                    /* filler for proper byte alignment */
  191. };
  192. typedef struct TRattnParams                TRattnParams;
  193.  
  194. struct TRstatusParams {
  195.     TPCCB                             statusCCB;                    /* pointer to ccb */
  196.     UInt16                             sendQPending;                /* pending bytes in send queue */
  197.     UInt16                             sendQFree;                    /* available buffer space in send queue */
  198.     UInt16                             recvQPending;                /* pending bytes in receive queue */
  199.     UInt16                             recvQFree;                    /* available buffer space in receive queue */
  200. };
  201. typedef struct TRstatusParams            TRstatusParams;
  202.  
  203. struct TRoptionParams {
  204.     UInt16                             sendBlocking;                /* quantum for data packets */
  205.     UInt8                             sendTimer;                    /* send timer in 10-tick intervals */
  206.     UInt8                             rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  207.     UInt8                             badSeqMax;                    /* threshold for sending retransmit advice */
  208.     UInt8                             useCheckSum;                /* use ddp packet checksum */
  209. };
  210. typedef struct TRoptionParams            TRoptionParams;
  211.  
  212. struct TRnewcidParams {
  213.     UInt16                             newcid;                        /* new connection id returned */
  214. };
  215. typedef struct TRnewcidParams            TRnewcidParams;
  216.  
  217. struct DSPParamBlock {
  218.     QElem *                            qLink;
  219.     short                             qType;
  220.     short                             ioTrap;
  221.     Ptr                             ioCmdAddr;
  222.     ADSPCompletionUPP                 ioCompletion;
  223.     OSErr                             ioResult;
  224.     StringPtr                         ioNamePtr;
  225.     short                             ioVRefNum;
  226.     short                             ioCRefNum;                    /* adsp driver refNum */
  227.     short                             csCode;                        /* adsp driver control code */
  228.     long                             qStatus;                    /* adsp internal use */
  229.     short                             ccbRefNum;
  230.     union {
  231.         TRinitParams                     initParams;
  232.         TRopenParams                     openParams;
  233.         TRcloseParams                     closeParams;            /*dspClose, dspRemove*/
  234.         TRioParams                         ioParams;                /*dspRead, dspWrite*/
  235.         TRattnParams                     attnParams;                /*dspAttention*/
  236.         TRstatusParams                     statusParams;            /*dspStatus*/
  237.         TRoptionParams                     optionParams;            /*dspOptions*/
  238.         TRnewcidParams                     newCIDParams;            /*dspNewCID*/
  239.     }                                 u;
  240. };
  241.  
  242. enum { uppADSPConnectionEventProcInfo = 0x0000B802 };             /* register no_return_value Func(4_bytes:A1) */
  243. enum { uppADSPCompletionProcInfo = 0x00009802 };                 /* register no_return_value Func(4_bytes:A0) */
  244. #define NewADSPConnectionEventProc(userRoutine)                 (ADSPConnectionEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  245. #define NewADSPCompletionProc(userRoutine)                         (ADSPCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  246. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  247.     #pragma parameter CallADSPConnectionEventProc(__A0, __A1)
  248.     void CallADSPConnectionEventProc(ADSPConnectionEventUPP routine, TPCCB sourceCCB) = 0x4E90;
  249. #else
  250.     #define CallADSPConnectionEventProc(userRoutine, sourceCCB)  CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  251. #endif
  252. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  253.     #pragma parameter CallADSPCompletionProc(__A1, __A0)
  254.     void CallADSPCompletionProc(ADSPCompletionUPP routine, DSPPBPtr thePBPtr) = 0x4E91;
  255. #else
  256.     #define CallADSPCompletionProc(userRoutine, thePBPtr)         CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  257. #endif
  258.  
  259.  
  260. #if PRAGMA_STRUCT_ALIGN
  261.     #pragma options align=reset
  262. #elif PRAGMA_STRUCT_PACKPUSH
  263.     #pragma pack(pop)
  264. #elif PRAGMA_STRUCT_PACK
  265.     #pragma pack()
  266. #endif
  267.  
  268. #ifdef PRAGMA_IMPORT_OFF
  269. #pragma import off
  270. #elif PRAGMA_IMPORT
  271. #pragma import reset
  272. #endif
  273.  
  274. #ifdef __cplusplus
  275. }
  276. #endif
  277.  
  278. #endif /* __ADSP__ */
  279.  
  280.